package com.keyancompany.zhongbaopingtai.adapter;

import android.support.v4.app.Fragment;
import android.support.v4.app.FragmentManager;
import android.support.v4.app.FragmentPagerAdapter;
import android.view.ViewGroup;

import com.keyancompany.zhongbaopingtai.fragment.TaskFragment;
import com.keyancompany.zhongbaopingtai.utils.DebugLog;

import java.util.ArrayList;
import java.util.List;

/**
 * Created by firefox on 2016/5/31.
 */
public class IFragmentPagerAdapter extends FragmentPagerAdapter {
    List<Fragment> fragmentList = new ArrayList<Fragment>();

//    List<String> titles = new ArrayList<>();

    String[] titles;

    public IFragmentPagerAdapter(FragmentManager fm, List<Fragment> fragmentList) {
        super(fm);
        this.fragmentList = fragmentList;
    }

    public void setTitles(String... titles) {
        this.titles = titles;
    }


    @Override
    public Fragment getItem(int position) {
        return fragmentList.get(position);
    }

    @Override
    public int getCount() {
        return fragmentList.size();
    }

    @Override
    public CharSequence getPageTitle(int position) {
        if (titles != null && titles.length > 0) {
            return titles[position];
        }
        return super.getPageTitle(position);
    }


}
